package com.bionic.banking.logic.controller;

import com.bionic.banking.core.entity.BankTransactionType;
import com.bionic.banking.dao.IBankTransactionTypeDao;
import com.bionic.banking.dao.classes.BankTransactionTypeDaoImpl;
import com.bionic.banking.dao.connection.LoggerLoader;
import com.bionic.banking.logic.exception.TransactionTypeNotFoundException;
import java.sql.SQLException;
import org.apache.log4j.Logger;

public class BankTransactionTypeController extends AbstractBean<BankTransactionType> 
{
    private static final Logger logger = LoggerLoader.getLogger(BankTransactionTypeController.class);

    @Override
    protected IBankTransactionTypeDao getDaoObject() {
        return new BankTransactionTypeDaoImpl();
    }

    public BankTransactionTypeController() throws InstantiationException, IllegalAccessException {
        super();
    }
    
   //@Override
    public BankTransactionType getByName(String name) throws TransactionTypeNotFoundException {
        try
        {
            return getDaoObject().findByName(name);
        }
        catch(SQLException ex)
        {
            logger.error(ex);
            throw new TransactionTypeNotFoundException("Transaction type '" + name + "' not found!" 
                    + ex.getMessage());
        }
    }
}
